package com.example.mahao_final.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.example.mahao_final.entity.User

@Dao
interface UserDao {

    // 插入一个用户
    @Insert
    suspend fun insertUser(user: User)

    // 根据用户名查询用户
    @Query("SELECT * FROM users WHERE username = :username LIMIT 1")
    suspend fun getUserByUsername(username: String): User?

    // 更新用户信息
    @Update
    suspend fun updateUser(user: User)

    // 获取所有用户
    @Query("SELECT * FROM users")
    suspend fun getAllUsers(): List<User>
}
